import java.util.Arrays;

public class Answer3 {
    //扑克牌顺子
    //https://www.nowcoder.com/practice/762836f4d43d43ca9deb273b3de8e1f4?tpId=13&tqId=11198&ru=/exam/oj
    public boolean IsContinuous (int[] numbers) {

        boolean[] hash=new boolean[14];
        int max=0,min=14;
        for(int i:numbers){
            if(i!=0){
                if(hash[i]) return false;
                hash[i]=true;

                max=Math.max(max,i);
                min=Math.min(min,i);
            }
        }

        return max-min<=4;
    }


    // 我的方法修改：缺少 值相同情况
    public static boolean IsContinuous2 (int[] numbers) {
        // write code here
        Arrays.sort(numbers);

        // 计算 0 的个数
        int sum = 0;
        for (int i = 0; i < numbers.length; i++) {
            if (numbers[i] == 0) {
                sum++;
            } else {
                break;
            }
        }
        // 用来记录差值
        int k = 0;
        int l = 0;
        for (int i = sum; i < numbers.length - 1; i++) {
            if(numbers[i + 1] == numbers[i]){
                return false;
            }
            if (numbers[i + 1] - numbers[i] != 1) {
                sum -= numbers[i + 1] - numbers[i] -1;
            }
        }
        if(sum>=0){
            return true;
        }else{
            return false;
        }

    }
}
